var oldVideoId = 'a1'

$('.list-wrapper').on('click', 'li', function () {
    $(this).addClass('active').siblings().removeClass('active');
    var index = $(this).index();
    $('.content').children().eq(index).show().siblings().hide();

    var currentContent = $('.content').children().eq(index);
    var currentVideoId = currentContent.find('.video-wrapper>div').attr('id');

    stopPlay(oldVideoId);
    playVideo(currentVideoId);
    oldVideoId = currentVideoId;
})

function playVideo(el) {
    var videoId = 'ckplayer_' + el
    var clientWidth = document.documentElement.clientWidth;
    var videoHeight = clientWidth / 16 * 9;
    var flashvars={
        f:'http://movie.ks.js.cn/flv/other/1_0.mp4',
        c:0,
        loaded:'loadedHandler'
    };
    var video=['http://movie.ks.js.cn/flv/other/1_0.mp4->video/mp4'];
    CKobject.embed('ckplayer/ckplayer.swf', el, videoId,'100%',videoHeight,false,flashvars,video);
}

function loadedHandler() {
}

function stopPlay(el) {
    var videoId = 'ckplayer_' + el
    CKobject.getObjectById(videoId).videoPause()
}

// 定义从第一个播放器开始播放
playVideo('a1');